<template>

    <div class="adminst">
    <van-nav-bar left-arrow :fixed="true">
      <template #right>
        <van-icon name="envelop-o" />
        <van-icon name="setting-o" @click="Popshow = true" />
      </template>
      <template #left>
        <div>我的</div>
      </template>
    </van-nav-bar>

   <van-popup
      v-model="Popshow"
      position="right"
      :style="{ width: '100%', height: '100%' }"
    >
      <Setting @showPopup="Popshow = false" @outPut="OutPut" ></Setting>
    </van-popup>
    <!-- 个人信息 -->
    <div>
      <div class="user" v-if="login">
        <div class="ziliao">
          <div class="left">
            <div class="touxiang">
              <!-- <i class="iconfont icon-jingshi"></i> -->
              <img :src="userInfo.avatar" alt="" />
            </div>
            <p class="username">{{ userInfo.nickname }}</p>
          </div>
          <div class="right">
            <p class="bianji" >个人主页</p>
            <van-icon name="arrow" size="14" />
          </div>
        </div>
        <div class="xinxi">
          <div class="toutiao">
            <p class="fontsize">1</p>
            <p>头条</p>
          </div>
          <div class="toutiao">
            <p class="fontsize">9</p>
            <p>获赞</p>
          </div>
          <div class="toutiao">
            <p class="fontsize">12</p>
            <p>粉丝</p>
          </div>
          <div class="toutiao">
            <p class="fontsize">8</p>
            <p>关注</p>
          </div>
        </div>
      </div>
      <div class="login" v-else>
        <p class="login_info">登录后头条更懂你<br />内容更有趣</p>
        <button class="login_button" @click="getLogin">立即登录</button>
      </div>
      <div class="likes">
        <div>
          <i class="iconfont icon-lingdang"></i>
          <p>消息通知</p>
        </div>
        <div>
          <i class="iconfont icon-shoucang"></i>
          <p>收藏</p>
        </div>
        <div @click="$router.push('/history')">
          <i class="iconfont icon-lishi"></i>
          <p>浏览历史</p>
        </div>
        <div @click="$router.push('/mypublic')">
          <i class="iconfont icon-wodefabu"></i>
          <p>我的发布</p>
        </div>
      </div>
    </div>
    <!-- 个人信息 -->

    <!-- 发布start -->
    <div class="public_my">
      <van-cell title="再小的想法，都值得被记录" :center="true">
        <template #right-icon>
          <van-button
            icon="plus"
            :round="true"
            color="#e54b43"
            class="public_button"
            @click="$router.push('/publish')"
            >发布</van-button
          >
        </template>
      </van-cell>
    </div>
    <!-- 发布end -->

    <div class="more_server">
      <van-cell value="全部" :center="true">
        <template #right-icon>
          <van-icon name="arrow" size="14"  />
        </template>
        <!-- 使用 title 插槽来自定义标题 -->
        <template #title>
          <h3 style="font-weight: 500">更多服务</h3>
        </template>
      </van-cell>

      <div class="servers">
        <van-row type="flex" justify="space-between" class="servers_row">
          <van-col span="4">
            <van-icon name="sign" />
            <div>任务</div>
          </van-col>
          <van-col span="4">
            <van-icon name="vip-card-o" />
            <div>VIP服务</div>
          </van-col>
          <van-col span="4">
            <van-icon name="service-o" />
            <div>客服中心</div>
          </van-col>
          <van-col span="4">
            <van-icon name="shield-o" />
            <div>安全中心</div>
          </van-col>
        </van-row>
        <van-row type="flex" justify="space-between" class="servers_row">
          <van-col span="4">
            <van-icon name="records" />
            <div>评论</div>
          </van-col>
          <van-col span="4">
            <van-icon name="good-job-o" />
            <div>点赞</div>
          </van-col>
          <van-col span="4">
            <van-icon name="question-o" />
            <div>问题</div>
          </van-col>
          <van-col span="4">
            <van-icon name="friends-o" />
            <div>关于我们</div>
          </van-col>
        </van-row>
      </div>
    </div>
    <Footer></Footer>
  </div>
</template>

<script>
import Footer from "@/views/Footer.vue";
import Setting from "./Setting.vue";
import { mapState } from "vuex";
export default {
  components: {
    Setting,
    Footer,
  },
  data() {
    return {
      login: true,
      Popshow: false,
    };
  },
  computed: {
    ...mapState(["userInfo"]),
  },
  methods: {
    OutPut() {
      setTimeout(() => {
        this.login = false;
      }, 2000);
    },
    getLogin() {
      localStorage.removeItem("token");
      setTimeout(() => {
        this.$router.push("/login");
      }, 1000);
    },
  },
  created() {
    let { token } = localStorage;
    if (token) {
      this.login = true;
    } else {
      this.login = false;
    }
  },
};
</script>

<style lang="less" scoped>
.van-nav-bar .van-icon {
  color: #000;
}
.van-icon {
  font-size: 20px;
}
.van-icon:first-child {
  margin: 0 18px;
}

.adminst {
  //   background-color: rgb(247, 247, 247);
  background-color: #f8f8f8;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 10px;
}
.login {
  margin-top: 28px;
  position: relative;
  height: 200px;
  background-image: url(//lf3-cdn2-tos.bytescm.com/toutiao/toutiao_web_pc/svgs/unlogin_bg.f00354c3.svg);
  .login_button {
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    color: #fff;
    background: #f04142;
    border-radius: 6px;
    position: absolute;
    top: 115px;
    left: 33%;
    padding: 8px 32px;
    border: none;
  }
  .login_info {
    font-size: 18px;
    line-height: 24px;
    font-weight: 500;
    color: #505050;
    padding: 60px 0 12px;
    background-size: contain;
    background-repeat: no-repeat;
    text-align: center;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }
}
.user {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  // background-color: pink;
  //   background: url("../../assets/1.jpg");
  .ziliao {
    display: flex;
    justify-content: space-between;
    padding: 30px 15px;
    .left {
      position: relative;
      .touxiang {
        position: relative;
        display: inline-block;
        width: 65px;
        height: 65px;
        border-radius: 50% 50%;
        background-color: #fff;
        .iconfont {
          font-size: 20px;
          color: rgb(157, 157, 157);
        }
        img {
          display: block;
          width: 65px;
          height: 65px;
          border-radius: 50% 50%;
          // position: absolute;
          // top: -6px;
          // left: -6px;
        }
      }
      .username {
        min-width: 100px;
        display: inline-block;
        font-size: 14px;
        color: #000;
        margin-left: 10px;
        position: absolute;
        top: 22px;
      }
    }

    .right {
      position: absolute;
      top: 80px;
      right: 15px;
      border-radius: 9px;
      color: rgb(144, 141, 141);
      display: flex;
      .van-icon{
        padding-top: 1px;
      }
      .bianji {
        font-size: 12px;
      }
    }
  }
  .xinxi {
    display: flex;
    justify-content: space-between;
    // padding: 0 2%;
    font-size: 12px;
    text-align: center;
    color: #000;
    font-family: Arial, Helvetica, sans-serif;
    margin: -10px 0 30px 0;
    .toutiao {
      flex: 1;
    }
    .fontsize {
      font-size: 14px;
    }
  }
}
.likes {
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 10px 5%;
  font-size: 12px;
  text-align: center;
  font-family: "微软雅黑";
  div {
    p {
      margin-top: 4px;
    }
  }
  .iconfont {
    font-size: 24px;
    color: #e54b43;
    margin-bottom: 10px;
  }
}

.public_my {
  margin: 10px 0;
  .public_button {
    width: 74px;
    height: 30px;
    font-size: 12px;
    .van-icon {
      margin: 0;
      font-size: 12px;
    }
  }
  ::v-deep .van-cell__title {
    flex: 2;
  }
}

.more_server {
  background-color: #fff;
  margin: 10px 0;
  padding-bottom: 5px;
  .servers {
    padding: 0 10px;
    text-align: center;
    font-size: 12px;
    div {
      margin-top: 3px;
    }
    .servers_row {
      margin: 5px 0;
      margin-bottom: 20px;
    }
  }
}

.btn {
  width: 100%;
  height: 40px;
  background-color: #fff;
  border: none;
  color: red;
}
</style>
